/**     
 * @Title: NettyEmbeddedServletContainerAutoConfiguration.java   
 * @Package me.springboot.netty.config   
 * @Description: TODO
 * @author weiwei 
 * @date 2017年8月25日 下午2:35:39   
 * @version V1.0     
 */
package me.springboot.netty.config;

import io.netty.bootstrap.Bootstrap;
import me.springboot.netty.factory.NettyEmbeddedServletContainerFactory;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

/**
 * @ClassName: NettyEmbeddedServletContainerAutoConfiguration
 * @Description: TODO
 * @author weiwei
 * @date 2017年8月25日 下午2:35:39
 * 
 */
@Order(Ordered.HIGHEST_PRECEDENCE)
@Configuration
@ConditionalOnWebApplication
@Import(EmbeddedServletContainerAutoConfiguration.BeanPostProcessorsRegistrar.class)
public class NettyEmbeddedServletContainerAutoConfiguration {

	@Configuration
	@ConditionalOnClass({ Bootstrap.class })
	@ConditionalOnMissingBean(value = EmbeddedServletContainerFactory.class, search = SearchStrategy.CURRENT)
	public static class EmbeddedNetty {
		
		@Bean
		public NettyEmbeddedServletContainerFactory nettyEmbeddedServletContainerFactory() {
			return new NettyEmbeddedServletContainerFactory();
		}
	}
}
